package com.vallis.asfc.controller;


import com.vallis.asfc.entity.AsfcExam;
import com.vallis.asfc.service.AsfcExamService;
import com.vallis.asfc.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author vallis
 * @since 2020-08-12
 */
@RestController
@CrossOrigin
@RequestMapping("/asfc-exam")
public class AsfcExamController {
    @Autowired
    private AsfcExamService asfcExamService;
    @GetMapping("getAllExam")
    public Result getAllExam(){

        return new Result(200,"获取成功",asfcExamService.list());
    }
    
    @GetMapping("getOneExam")
    public Result getOneExam(Long id) {
        
        return new Result(200, "获取成功", asfcExamService.getById(id));
    }
    
    @PutMapping("addExam")
    public Result addExam(@RequestBody AsfcExam asfcExam) {
        System.out.println(asfcExam);
        return new Result(200, "获取成功", asfcExamService.save(asfcExam));
        
    }
    
    @PutMapping("removeExam")
    public Result removeExam(Long id) {
        
        return new Result(200, "获取成功", asfcExamService.removeById(id));
    }
    
    @PutMapping("updateExam")
    public Result updateExam(@RequestBody AsfcExam asfcExam) {
        
        return new Result(200, "获取成功", asfcExamService.saveOrUpdate(asfcExam));
    }


}
